/* 
 *
 * 微信公众号测试DEMO
 *
 */
var express = require('express');
var path = require('path');
var bodyParser = require('body-parser');
var app = express();
var wechat = require('./controller/wechat');

	// 设置模板引擎
app.set('views', path.join(__dirname, 'views/pages'));
app.set('view engine', 'jade');
app.use(bodyParser.urlencoded({
	extended: true
}));
// 设置静态文件路径
app.use(bodyParser.json());
app.use(express.static(path.join(__dirname, 'public')));

// 微信处理通道
app.all('/controller/wechat', function(req, res) {
	wechat.process(req, res);
});

module.exports = app;
app.set('port', process.env.PORT || 3000);
var server = app.listen(app.get('port'), function() {
	console.log('----------------------------------------------------------------------------');
	console.log("Express server listening on port %s:%d in %s mode", server.address().address, server.address().port, app.settings.env);
	console.log('----------------------------------------------------------------------------');
});
